<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <input id="input" type="text"/>
        <button onclick="send()">Send</button>
        <pre id="output"></pre>
        <script>
            /**@type HTMLInputElement*/
            var input = document.getElementById("input")
            var output = document.getElementById("output")
            var socket = new WebSocket("ws://localhost:8080/echo")

            socket.onopen = function(){
                output.innerHTML += "Status: Connected\n";
            }

            socket.onmessage = function(e){
                output.innerHTML += "Server: "+e.data + "\n"
            }

            function send(){
                socket.send(input.value);
                input.value = ""
            }

        </script>
    </body>
</html>